import BaseController from '../lib/base-controller';
import { RequestMapping, POST } from '../lib/add-router';
import auth from '../lib/auth';

@RequestMapping('/upload')
export class UploadController extends BaseController {
  @POST('/cos')
  @auth
  public async cosUpload() {
    const { ctx } = this;
    const { statusCode, Location, RequestId } = await ctx.service.upload.upload(ctx.request.files[0]) as any;
    this.success({ path: 'https://' + Location, uid: RequestId }, '上传成功!', statusCode);
  }
}
